from rest_framework import serializers
from goods.models import SPUSpecification, SpecificationOption


# spu的specs的序列化器
class SPUspecsViewSerializer(serializers.ModelSerializer):

    # 由于名称和id展示不出来，要重写
    spu = serializers.StringRelatedField(read_only=True) # 重写外键。多方不写。
    spu_id = serializers.IntegerField()

    class Meta:
        model = SPUSpecification
        fields = "__all__"


# specs的Option序列化器
class SpecsOptionViewSerializer(serializers.ModelSerializer):

    # 由于名称和id展示不出来，要重写
    spec = serializers.StringRelatedField(read_only=True) # 重写外键。多方不写。
    spec_id = serializers.IntegerField()

    class Meta:
        model = SpecificationOption
        fields = "__all__"